import axios from "axios";
import 'nprogress/nprogress.css';
import NProgress from 'nprogress'

let mockajax = axios.create({
    baseURL:'/mock',
    timeout:1000
})

mockajax.interceptors.request.use(
    conflg =>{
        NProgress.start();
        return conflg
    },
    error =>{

        return Promise.reject(error)
    }
)

mockajax.interceptors.response.use(
    res => {
       NProgress.done()
        return res.data
    },
    error =>{
        NProgress.done()
        return Promise.reject(error)
    }
)

export default mockajax